package com.goodving.guli.bt.lua;

import android.content.Context;
import android.graphics.Bitmap;
import android.widget.ImageView;

import com.goodving.guli.bt.Utils;
import com.goodving.guli.bt.profile.scale.C3515h;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.ImageSize;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
import com.nostra13.universalimageloader.utils.DiskCacheUtils;
import com.nostra13.universalimageloader.utils.MemoryCacheUtils;

import java.io.File;
import java.util.List;

/**
 * Created by john on 2015/12/1.
 */
public class C1226h {
    private static C1226h f6470a;
    private DisplayImageOptions f6471b; //C3078d
    private ImageLoader f6472c; // C3088g

    private C1226h(Context context) {
        m11374b(context);
    }

    public static C1226h m11372a() {
        return f6470a;
    }

    public static void m11373a(Context context) {
        f6470a = new C1226h(context);
    }

    private void m11374b(Context context) {
        ImageLoaderConfiguration c = new ImageLoaderConfiguration.Builder(context).threadPriority(5).denyCacheImageMultipleSizesInMemory().diskCacheFileNameGenerator(new Md5FileNameGenerator()).tasksProcessingOrder(QueueProcessingType.LIFO).memoryCache(new LruMemoryCache(4194304)).memoryCacheSize(4194304).diskCache(new UnlimitedDiskCache(new File(Utils.m8079j(context)))).diskCacheSize(52428800).diskCacheFileCount((int) C3515h.f17660E).writeDebugLogs().build();
//        C3091j c = new C3093l(context).m22377b(5).m22364a().m22379b(new C3028c()).m22371a(C3057h.LIFO).m22370a(new C3038f(4194304)).m22383c(4194304).m22380b(new C3025c(new File(Utils.m8079j(context)))).m22386f(52428800).m22388h((int) C3515h.f17660E).m22376b().m22382c();
        this.f6472c = ImageLoader.getInstance();//m22302a();
        this.f6472c.init(c);//m22310a(c);
        this.f6471b = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).build();
        //this.f6471b = new C3086f().m22289b(true).m22296d(true).m22294d();
    }

    public Bitmap m11375a(String str) {
        return this.f6472c.loadImageSync(str);
    }

    public Bitmap m11376a(String str, ImageSize c3055f) {
        return this.f6472c.loadImageSync(str, c3055f);
    }

    public void m11377a(String str, ImageView imageView) {
        this.f6472c.displayImage(str, imageView, this.f6471b);
    }

    public void m11378a(String str, ImageView imageView, ImageLoadingListener c0701a) {
        this.f6472c.displayImage(str, imageView, this.f6471b, c0701a);
    }

    public void m11379a(String str, ImageSize c3055f, ImageLoadingListener c0701a) {
        this.f6472c.loadImage(str, c3055f, c0701a);
    }

    public void m11380a(String str, ImageLoadingListener c0701a) {
        this.f6472c.loadImage(str, new DisplayImageOptions.Builder().cacheInMemory(false).cacheOnDisc(true).build(), c0701a); // m22319a
    }

    public Bitmap m11381b(String str, ImageSize c3055f) {
        return this.f6472c.loadImageSync(str, c3055f, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).build()); // m22306a
    }

    public List<Bitmap> m11382b(String str) {
        // return C3111g.m22459a(str, this.f6472c.m22331c());
        return  MemoryCacheUtils.findCachedBitmapsForImageUri(str, this.f6472c.getMemoryCache());
    }

    public void m11383b(String str, ImageView imageView) {
        //this.f6472c.displayImage(str, imageView, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).m22280a(new C1318i(this)).build());
        this.f6472c.displayImage(str, imageView, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).displayer(new C1318i(this)).build());

    }

    public void m11384b(String str, ImageView imageView, ImageLoadingListener c0701a) {
        // this.f6472c.loadImage(str, imageView, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).m22280a(new C1318i(this)).build(), c0701a); // m22313a
        this.f6472c.displayImage(str, imageView,
                new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).displayer(new C1318i(this)).build(), c0701a); // m22313a
    }

    public void m11385b(String str, ImageLoadingListener c0701a) {
        this.f6472c.loadImage(str, c0701a); // m22325a
    }

    public File m11386c(String str) {
        // return C3106a.m22435a(str, this.f6472c.m22334f());
        return DiskCacheUtils.findInCache(str, this.f6472c.getDiskCache());
    }

    public void m11387d(String str) {
//        C3111g.m22461c(str, this.f6472c.m22331c());
        MemoryCacheUtils.removeFromCache(str, this.f6472c.getMemoryCache());
//        C3106a.m22436b(str, this.f6472c.m22334f());
        //package com.p041f.p042a.p167c;
        DiskCacheUtils.removeFromCache(str, this.f6472c.getDiskCache());
    }
}
